home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / upplow / upplow.bas < prev    next >
BASIC Source File  |  1995-03-01  |  1KB  |  30 lines

  1. ' UppLow.bas - Force Upper or Lower Case in a Text Box
  2. ' 95/03/02 Copyright 1995, Larry Rebich, The Bridge, Inc.
  3.  
  4.     Option Explicit
  5.     DefInt A-Z
  6.     
  7.     Declare Function GetWindowLong Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer) As Long
  8.     Declare Function SetWindowLong Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Long) As Long
  9.  
  10. Function ForceUpperOrLowerCase (TheControl As Control, SetUpper As Integer) As Integer
  11. ' If SetUpper is true then set to upper case, else lower case
  12. ' Returns True if successful
  13.     Const GWL_Style = (-16)
  14.     Const ES_UPPERCASE = &H8&
  15.     Const ES_LOWERCASE = &H10&
  16.     Dim Rtn As Long
  17.     Dim Style As Long
  18.     Style = GetWindowLong(TheControl.hWnd, GWL_Style)
  19.     If SetUpper Then                    'upper?
  20.         Style = Style Or ES_UPPERCASE   'yes, set upper
  21.     Else
  22.         Style = Style Or ES_LOWERCASE   'no, set lower
  23.     End If
  24.     Rtn = SetWindowLong(TheControl.hWnd, GWL_Style, Style)  'do it
  25.     If Rtn <> 0 Then                    'if not zero then was successful
  26.         ForceUpperOrLowerCase = True
  27.     End If
  28. End Function
  29.  
  30.